/**
 * 用户model,信息收集
 */
'use strict'
import {fetchOrderList} from "../services/userService";

export default {

  namespace: 'user',

  state: {
    info: {},//信息收集表单
    isFirstTest: false,//是否进行过首次测试
    orderList: [],//订单列表
  },

  subscriptions: {
    setup({dispatch, history}) {  // eslint-disable-line
    },
  },

  effects: {
    * fetchOrderList(a, {call, put}) {  //取得订单列表
      const {data} = yield call(_ => fetchOrderList()) || {};
      const {orderList = []} = data;
      yield put({type: 'orderList', payload: orderList});
    },
  },

  reducers: {
    orderList(state = {}, action) {
      return {...state, orderList: action.payload};
    },
    info(state = {}, {payload = {}}) {
      return {...state, info: payload};
    },
  },

};
